/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package es.revuel.tvponce.beans.tablas;

import es.revuel.tpvonce.modelo.vo.ArticuloVO;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author Usuario
 */
public class ModeloTablaArticulos extends ListDataModel<ArticuloVO> implements SelectableDataModel<ArticuloVO>{

    public ModeloTablaArticulos(){
        
    }
    
    public ModeloTablaArticulos (List<ArticuloVO> listaDeArticulos){
        super(listaDeArticulos);
    }
    
    @Override
    public Object getRowKey(ArticuloVO articulo) {
        return articulo.getIdentificador();
    }

    @Override
    public ArticuloVO getRowData(String rowKey) {
        
         List<ArticuloVO>articulos = (List<ArticuloVO>) getWrappedData();  
          
        for(ArticuloVO f : articulos) {  
            if(f.getIdentificador().equals(rowKey))  
                return f;  
        }  
          
        return null;  
        
    }
    
    
    
}
